<?php

use dali\Send;

include "src/Send.php";

$send = new Send(['自己的邮箱地址', '授权码']);

$js_url = "http://open.iciba.com/dsapi/";//每日一句接口

$result = http($js_url);

$send_name = '爱你的张三';//发送人的昵称
$to_user_email = ['xiaomei@qq.com'];//发送对象,如需群发只需要将格式修改为['邮箱1','邮箱2','邮箱3'......]
$title = "每日一句";//邮件标题
$content = "英文:{$result['content']},中文为:{$result['note']}";//邮件类容

$ret = $send->send($send_name, $to_user_email, $title, $content);

var_dump($ret);die();

function http($url, $data = [])
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

    if (!empty($data)) {
        if (is_array($data)) {
            $data = json_encode($data);
        }
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    }
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $res = curl_exec($curl);
    $errorno = curl_errno($curl);
    if ($errorno) {
        return array('errorno' => false, 'errmsg' => $errorno);
    }
    curl_close($curl);

    return json_decode($res, true);
}


?>